<!--suppress ALL -->
<include file="./Template/header.html" />

<link rel="stylesheet" type="text/css" href="/Template/css/exam.css">
<script type="text/javascript" src="/Template/js/amazeui.js"></script>
<script type="text/javascript">


    $(function() {

        //初始化页面配置
        initPage("测量对线");

        $("select[name=sex]").change(function() {
            var value = $(this).val();
            $(this).prev().val(value);
        });

        $("input[name=r1Angle]").click(function(){
            if($(this).val() == "other"){
                $("#r1AngleOther").focus();
            }else{
                $("#r1AngleOther").val("");
            }
        });
        $("#r1AngleOther").click(function(){
            $("input[name='r1Angle']").get(4).checked=true;
        });
        if(!isNullOrEmpty($("input[name=heelHeadAngle]").val())){
            $(".checkline_second.heelHeadAngle").show();
        }
        $("input[name=heelHead]").click(function(){
            if($(this).val() != 0){
                $("#heelHeadAngle").focus();
                $(".checkline_second.heelHeadAngle").show();
            }else{
                $(".checkline_second.heelHeadAngle").hide();
                $("#heelHeadAngle").val("");
            }
        });
        $("#heelHeadAngle").click(function(){
            $("input[name=heelHead]").get(0).checked=false;
        });
        if(!isNullOrEmpty($("input[name=forefootHeadAngle]").val())){
            $(".checkline_second.forefootHeadAngle").show();
        }
        $("input[name=forefootHead]").click(function(){
            if($(this).val() != "0"){
                $("#forefootHeadAngle").focus();
                $(".checkline_second.forefootHeadAngle").show();
            }else{
                $(".checkline_second.forefootHeadAngle").hide();
                $("#forefootHeadAngle").val("");
            }
        });
        $("#forefootHeadAngle").click(function(){
            $("input[name=forefootHead]").get(0).checked=false;
        });

        var app = new Vue({
            el: '#container',
            data: {
            },
            methods: {
                checkRole: function(employeeRoleId, roleId) {
                    var employeeRoleArr = employeeRoleId.split(",");
                    var roleArr = roleId.split(",");

                    var result = false;
                    $.each(roleArr, function(i,val){
                        if($.inArray(val, employeeRoleArr) != -1 || $.inArray((parseInt(val)+100).toString(), employeeRoleArr) != -1){
                            result = true;
                        }
                    });
                    return result;
                },
                cancel: function() {
                    window.location.href = "/wechat/workorder/index/id/{$workorderId}";
                },
                save: function() {
                    var examMeasureId = $("input[name=examMeasureId]").val();
                    var workorderId = $("input[name=workorderId]").val();

                    var shank0 = $("input[name=shank0]").val();
                    var shank1 = $("input[name=shank1]").val();
                    var shank2 = $("input[name=shank2]").val();
                    var shank3 = $("input[name=shank3]").val();
                    var shank4 = $("input[name=shank4]").val();
                    var shank5 = $("input[name=shank5]").val();
                    var shank6 = $("input[name=shank6]").val();
                    var shank7 = $("input[name=shank7]").val();
                    var shank8 = $("input[name=shank8]").val();
                    var shank9 = $("input[name=shank9]").val();
                    var shank10 = $("input[name=shank10]").val();
                    var shank11 = $("input[name=shank11]").val();
                    var shank12 = $("input[name=shank12]").val();
                    var r1 = $("select[name=r1]").val();
                    var r1Angle = $("input[name=r1AngleOther]").val();
                    var r2 = $("select[name=r2]").val();
                    var r2Angle = $("input[name=r2Angle]").val();
                    var heelHead = $("input[name=heelHeadAngle]").val();
                    var forefootHead = $("input[name=forefootHeadAngle]").val();
//                    var sva = $("input[name=sva]").val();

                    var completed = "1";
                    if(isNullOrEmpty(shank0
                            && shank1
                            && shank2
                            && shank3
                            && shank4
                            && shank5
                            && shank6
                            && shank7
                            && shank8
                            && shank9
                            && shank10
                            && shank11
                            && shank12
                            && r1
                            && r2
                            && r2Angle
//                            && sva
                        )) {
                        completed = "-1";
                    }
                    if(isNullOrEmpty(r1Angle)) {
                        if($("input[name='r1Angle']:checked").val() == 'other'){
                            alert("【R1】角度未输入");
                            $("input[name=r1AngleOther]").focus();
                            return;
                        }else{
                            r1Angle = $("input[name='r1Angle']:checked").val();
                        }
                    }

                    if(isNullOrEmpty(heelHead)) {
                        if($("input[name='heelHead']:checked").val() == 0){
                            heelHead = 0;
                        }else{
                            completed = "-1";
                        }
                    }else{
                        if(isNullOrEmpty($("input[name='heelHead']:checked").val())){
                            alert("【后足冠状面】未选取");
                            $("input[name=heelHeadAngle]").focus();
                            return;
                        }
                        heelHead = Math.abs(heelHead) * $("input[name='heelHead']:checked").val();
                    }
                    if(isNullOrEmpty(forefootHead)) {
                        if($("input[name='forefootHead']:checked").val() == 0){
                            forefootHead = 0;
                        }else{
                            completed = "-1";
                        }
                    }else{
                        if(isNullOrEmpty($("input[name='forefootHead']:checked").val())){
                            alert("【前足冠状面】未选取");
                            $("input[name=forefootHeadAngle]").focus();
                            return;
                        }
                        forefootHead = Math.abs(forefootHead) * $("input[name='forefootHead']:checked").val();
                    }

                    $.ajax({
                        url:"/wechat/workorder/examMeasurePost",
                        type:"post",
                        data:{
                            examMeasureId: examMeasureId,
                            workorderId: workorderId,
                            shank0: shank0,
                            shank1: shank1,
                            shank2: shank2,
                            shank3: shank3,
                            shank4: shank4,
                            shank5: shank5,
                            shank6: shank6,
                            shank7: shank7,
                            shank8: shank8,
                            shank9: shank9,
                            shank10: shank10,
                            shank11: shank11,
                            shank12: shank12,
                            r1: r1,
                            r1Angle: r1Angle,
                            r2: r2,
                            r2Angle: r2Angle,
                            heelHead: heelHead,
                            forefootHead: forefootHead,
//                            sva: sva,
                            completed:completed,
                        },
                        dataType:"JSON",
                        beforefootSend:function(){
                            $("#loadingToast").show();
                        },
                        complete:function(){
                            $('#loadingToast').hide();
                        },
                        success:function(data){
                            if(data.code == 200) {
//                                alert(data.alert);
                                alert("保存成功");
                                window.location.href = "/wechat/workorder/index/id/{$workorderId}";
                            }
                        },
                    })

                }
            }
        })
        $(".item select").change(function() {
            var value = $(this).find("option:selected").text();
            $(this).prev().val(value);
        });
    })

</script>

<div class="container" id="container">
    <div class="hint-info">
        <span class="update_time">{$formDict.update_time}：{$examMeasure.update_time}</span>
        <span class="employee_name">{$formDict.update_name}：{$employeeName}</span>
    </div>
    <div class="bg">
        <img class="bg-img" src="http://xwk-file.oss-cn-qingdao.aliyuncs.com/Home/exam_measure_wechat.jpg" alt="bg">
    </div>
    <div class="edit-info">
        <div class="edit-content">
            <input type="text" style="display: none;" name="workorderId" value="{$workorderId}">
            <input type="text" style="display: none;" name="examMeasureId" value="{$examMeasureId}">

            <div class="item"><span>1.{$formDict.shank_0}:</span><input name="shank0" type="text" value="{$examMeasure.shank_0}" placeholder="请输入数据(mm)" ></div>
            <div class="item"><span>2.{$formDict.shank_1}:</span><input name="shank1" type="text" value="{$examMeasure.shank_1}" placeholder="请输入数据(mm)" ></div>
            <div class="item"><span>3.{$formDict.shank_2}:</span><input name="shank2" type="text" value="{$examMeasure.shank_2}" placeholder="请输入数据(mm)" ></div>
            <div class="item"><span>4.{$formDict.shank_3}:</span><input name="shank3" type="text" value="{$examMeasure.shank_3}" placeholder="请输入数据(mm)" ></div>
            <div class="item"><span>5.{$formDict.shank_4}:</span><input name="shank4" type="text" value="{$examMeasure.shank_4}" placeholder="请输入数据(mm)" ></div>
            <div class="item"><span>6.{$formDict.shank_5}:</span><input style="width: 32%;" name="shank5" type="text" value="{$examMeasure.shank_5}" placeholder="请输入数据(mm)" ></div>
            <div class="item"><span style="width: 65%;">7.{$formDict.shank_6}:</span><input style="width: 32%;" name="shank6" type="text" value="{$examMeasure.shank_6}" placeholder="请输入数据(mm)" ></div>
            <div class="item"><span>8.{$formDict.shank_7}:</span><input name="shank7" type="text" value="{$examMeasure.shank_7}" placeholder="请输入数据(mm)" ></div>
            <div class="item"><span>9.{$formDict.shank_8}:</span><input name="shank8" type="text" value="{$examMeasure.shank_8}" placeholder="请输入数据(mm)" ></div>
            <div class="item"><span>10.{$formDict.shank_9}:</span><input name="shank9" type="text" value="{$examMeasure.shank_9}" placeholder="请输入数据(mm)" ></div>
            <img class="bg-img" src="http://xwk-file.oss-cn-qingdao.aliyuncs.com/Home/drafo2_wechat.jpg" alt="bg">
            <div class="item"><span style="width: 65%;">11.{$formDict.shank_10}:</span><input style="width: 32%;" name="shank10" type="text" value="{$examMeasure.shank_10}" placeholder="请输入数据(mm)" ></div>
            <div class="item"><span style="width: 65%;">12.{$formDict.shank_11}:</span><input style="width: 32%;" name="shank11" type="text" value="{$examMeasure.shank_11}" placeholder="请输入数据(mm)" ></div>
            <div class="item"><span style="width: 65%;">13.{$formDict.shank_12}:</span><input style="width: 32%;" name="shank12" type="text" value="{$examMeasure.shank_12}" placeholder="请输入数据(mm)" ></div>

            <div class="item" style="border-bottom:0px">
                <span class="itemTitle"></span>
            </div>
            <div class="item" style="border-bottom:0px">
                <span>R1：</span>
                <php>
                    $r1Name = $formDict["range_".$examMeasure["r1"]];
                </php>
                <input id="r1" type="text" value="{$r1Name}" readonly placeholder="请选择">
                <select name="r1">
                    <option value="{$examMeasure.r1}">请选择</option>
                    {:getFormDictSelectOptionHtml($examMeasure['r1'],'range','exam_measure',0)}
                </select>
                <img class="icon-right" src="/Template/images/icon-right.png" alt="">
            </div>
            <div class="item" id="r1AngleCheck" style="border-bottom:0px">
                <div class="checkline_second">
                    <php>
                        if(in_array($examMeasure["r1_angle"], array('90','-5','-10','-15'))){
                            $r1Angle[$examMeasure["r1_angle"]] = "checked";
                        }else{
                            $r1Angle["other"] = "checked";
                        }
                    </php>
                    <input name="r1Angle" class="checkFirst" value="90" type="radio"  {$r1Angle[90]}>90
                    <input name="r1Angle" class="checkOther" value="-5" type="radio"  {$r1Angle[-5]}>-5
                    <input name="r1Angle" class="checkOther" value="-10" type="radio"  {$r1Angle[-10]}>-10
                    <input name="r1Angle" class="checkOther" value="-15" type="radio"  {$r1Angle[-15]}>-15
                    <input name="r1Angle" class="checkOther" value="other" type="radio"  {$r1Angle[other]}  v-on:click="r1AngleOtherCheck">其他角度
                    <if condition="$r1Angle['other'] eq 'checked'">
                        <input name="r1AngleOther" id="r1AngleOther" class="otherAngle" type="text" value="{$examMeasure.r1_angle}" placeholder="请输入">
                    <else/>
                        <input name="r1AngleOther" id="r1AngleOther" class="otherAngle" type="text" value="" placeholder="请输入">
                    </if>
                </div>
            </div>
            <div class="item" style="border-bottom:0px">
                <span>R2：</span>
                <php>
                    $r2Name = $formDict["range_".$examMeasure["r2"]];
                </php>
                <input id="r2" type="text" value="{$r2Name}" readonly placeholder="请选择">
                <select name="r2">
                    <option value="{$examMeasure.r2}">请选择</option>
                    {:getFormDictSelectOptionHtml($examMeasure['r2'],'range','exam_measure',0)}
                </select>
                <img class="icon-right" src="/Template/images/icon-right.png" alt="">
            </div>
            <div class="checkline_second">
                角度：<input name="r2Angle" id="r2Angle" class="otherAngle" type="text"
                          value="{$examMeasure.r2_angle}" placeholder="请输入">
            </div>
            <!--<div class="item" style="border-bottom:0px"><span>R2:</span><input name="r2Angle" type="text" value="{$examMeasure.r2_angle}" placeholder="请输入数据" ></div>-->

            <div class="item" id="heelHeadCheck" style="border-bottom:0px">
                <span>{$formDict.heel_head}：</span>
                <div class="checkline_first">
                    <php>
                        if($examMeasure["heel_head"] == 0){
                            $heelHead["0"] = "checked";
                            $heelHeadAngle = "";
                        }
                        else{
                            if($examMeasure["heel_head"] < 0)
                                $heelHead["-1"] = "checked";
                            else
                                $heelHead["1"] = "checked";
                            $heelHeadAngle = abs($examMeasure["heel_head"]);
                        }
                    </php>
                    <input name="heelHead" class="checkFirst" value="0" type="radio" {$heelHead[0]}>{$formDict.head_0}
                    <input name="heelHead" class="checkOther" value="-1" type="radio" {$heelHead[-1]}>{$formDict.head_1}
                    <input name="heelHead" class="checkOther" value="1" type="radio" {$heelHead[1]}>{$formDict.head_2}
                </div>
                <div class="checkline_second heelHeadAngle" style="display: none">
                    角度：<input name="heelHeadAngle" id="heelHeadAngle" class="otherAngle" type="text"
                              value="{$heelHeadAngle}" placeholder="请输入">
                </div>
            </div>
            <div class="item" id="forefootHeadCheck" style="border-bottom:0px">
                <span>{$formDict.forefoot_head}：</span>
                <div class="checkline_first">
                    <php>
                        if($examMeasure["forefoot_head"] == 0){
                        $forefootHead["0"] = "checked";
                        $forefootHeadAngle = "";
                        }
                        else{
                        if($examMeasure["forefoot_head"] < 0)
                        $forefootHead["-1"] = "checked";
                        else
                        $forefootHead["1"] = "checked";
                        $forefootHeadAngle = abs($examMeasure["forefoot_head"]);
                        }
                    </php>
                    <input name="forefootHead" class="checkFirst" value="0" type="radio" {$forefootHead[0]}>{$formDict.head_0}
                    <input name="forefootHead" class="checkOther" value="-1" type="radio" {$forefootHead[-1]}>{$formDict.head_1}
                    <input name="forefootHead" class="checkOther" value="1" type="radio" {$forefootHead[1]}>{$formDict.head_2}
                </div>
                <div class="checkline_second forefootHeadAngle" style="display: none">
                    角度：<input name="forefootHeadAngle" id="forefootHeadAngle" class="otherAngle" type="text"
                              value="{$forefootHeadAngle}" placeholder="请输入">
                </div>
            </div>
            <!--<div class="item"><span>SVA:</span><input name="sva" type="text" value="{$examMeasure.sva}" placeholder="请输入数据" ></div>-->


            <div class="line"></div>
        </div>
    </div>
    <div class="operation-btn">
        <div class="cancle-btn" v-on:click="cancel">取消</div>
        <if condition="$workorder['status'] eq '-1' && $workorder['creator_id'] eq $customerId">
            <div class="save-btn" v-on:click="save">保存</div>
        </if>
        <if condition="$workorder['status'] eq '2' && $workorder['examinator_id'] eq $customerId && $workorder['exam_time'] eq ''">
            <div class="save-btn" v-on:click="save">保存</div>
        </if>
        <div v-if="{$workorder.status} >= 1 && checkRole('{$role}', '1')">
            <div class="save-btn" v-on:click="save">保存</div>
        </div>
    </div>

</div>
<include file="./Template/footer.html" />